package demo;

import com.jfinal.config.*;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;
import demo.config.FrontRoute;
import demo.model.Zperson;
import demo.model._MappingKit;

/**
 * @author ml
 * @create 2017-12-26--11:11
 */
public class DemoConfig extends JFinalConfig {
    @Override
    public void configConstant(Constants constants) {
        constants.setDevMode(true);
    }

    @Override
    public void configRoute(Routes routes) {

        //routes.add("/hello",HelloController.class);
        routes.add(new FrontRoute());
    }

    @Override
    public void configEngine(Engine engine) {

    }

    @Override
    public void configPlugin(Plugins plugins) {


        loadPropertyFile("db.properties");
        DruidPlugin dp=new DruidPlugin(getProperty("jdbcUrl"),getProperty("user"),getProperty("password"));
        plugins.add(dp);

        ActiveRecordPlugin arp=new ActiveRecordPlugin(dp);
        arp.setDialect(new SqlServerDialect());
        arp.setShowSql(true);
        arp.setDevMode(true);
        plugins.add(arp);
        arp.addMapping("zperson","proid", Zperson.class);
        _MappingKit.mapping(arp);

    }

    @Override
    public void configInterceptor(Interceptors interceptors) {

    }

    @Override
    public void configHandler(Handlers handlers) {

    }
}
